/*
 * Copyright (C) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "gtest/gtest.h"
#include <memory>
#include <thread>
#define private public
#define protected public
#include "lru_cache_util.h"
#undef private
#undef protected

namespace OHOS::AppDomainVerify {
using namespace testing;
using namespace testing::ext;
class LruCacheUtilTest : public testing::Test {
public:
    static void SetUpTestCase(void);
    static void TearDownTestCase(void);
    void SetUp();
    void TearDown();
};

void LruCacheUtilTest::SetUpTestCase(void)
{
}

void LruCacheUtilTest::TearDownTestCase(void)
{
}

void LruCacheUtilTest::SetUp(void)
{
}

void LruCacheUtilTest::TearDown(void)
{
}

/**
 * @tc.name: LruCacheUtilTest001
 * @tc.desc: fundation function test example string
 * @tc.type: FUNC
 */
HWTEST_F(LruCacheUtilTest, LruCacheUtilTest001, TestSize.Level0)
{
    auto lruCache = LruCacheUtil<std::string, std::string>();
    for (int i = 0; i < 11; i++) {
        lruCache.Put(std::to_string(i), std::to_string(i));
    }
    std::string value;
    ASSERT_FALSE(lruCache.Get("0", value));
    ASSERT_TRUE(lruCache.Get("1", value));
    ASSERT_EQ(value.compare("1"), 0);
    for (int i = 0; i < 3; i++) {
        lruCache.Put(std::to_string(i + 11), std::to_string(i + 11));
    }
    ASSERT_TRUE(lruCache.Get("1", value));
    ASSERT_EQ(value.compare("1"), 0);
    lruCache.Clear();
    ASSERT_FALSE(lruCache.Get("1", value));
}

}